<template>
  <div class="home">
    <a-button @click="handleClick" type="primary">发布公告</a-button>
    <a-modal v-model:visible="visible" @ok="handleOk" @cancel="handleCancel">
      <template #title> 发布通告</template>
      <div style="height: 300px; width: 400px; text-align: center">
        <a-space style="margin-top: 20px; margin-bottom: 20px">
          <a-input
            :style="{ width: '320px' }"
            v-model="form.name"
            default-value="主题"
            placeholder="主题"
            allow-clear
          />
        </a-space>
        <a-space style="margin-top: 20px; margin-bottom: 20px">
          <a-input
            :style="{ width: '320px' }"
            v-model="form.publisher"
            default-value="发布人"
            placeholder="发布人"
            allow-clear
          />
        </a-space>
        <a-space style="margin-top: 20px; margin-bottom: 20px">
          <a-textarea
            style="width: 320px; height: 100px"
            v-model="form.context"
            placeholder="内容"
            allow-clear
          />
        </a-space>
      </div>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from "vue";
import { Announcement, AnnouncementControllerService } from "../../generated";

const visible = ref(false);
const form = reactive({
  annexExist: "",
  annexName: "",
  context: "",
  id: undefined,
  name: "",
  publisher: "",
} as Announcement);
const handleClick = () => {
  visible.value = true;
};
const handleOk = () => {
  AnnouncementControllerService.addannouncementUsingPost(form);
  visible.value = false;
};
const handleCancel = () => {
  visible.value = false;
};
</script>
